package com.wdd.owntool

import android.os.Bundle
import android.widget.ListView
import androidx.appcompat.app.AppCompatActivity
import com.alibaba.android.arouter.launcher.ARouter
import com.blankj.utilcode.util.ActivityUtils
import com.blankj.utilcode.util.LogUtils
import com.wdd.libbase.view.antiShakeItemClick
import com.wdd.owntool.adapter.MainAdapter
import com.wdd.owntool.bean.ArouterTest
import com.wdd.owntool.ui.RxPermissionActivity
import com.wdd.owntool.ui.lazy.LazyActivity
import com.wdd.owntool.ui.mvp.MvpActivity
import com.wdd.owntool.ui.refresh.SmartRefreshActivity


class MainActivity : AppCompatActivity() {
    private lateinit var listView: ListView
    private var items = listOf<String>(
        "MVP模式（Dagger2）",
        "列表刷新",
        "RxPermissions权限请求",
        "Arouter传值测试",
        "懒加载fragment",
        "快速点击"
    )


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        listView = findViewById(R.id.list_view)
        val adapter = MainAdapter(this, items)
        listView.adapter = adapter
        listView.antiShakeItemClick { view, position, id ->
            when (position) {
                0 -> ActivityUtils.startActivity(MvpActivity::class.java)
                1 -> ActivityUtils.startActivity(SmartRefreshActivity::class.java)
                2 -> ActivityUtils.startActivity(RxPermissionActivity::class.java)
                3 -> ARouter.getInstance().build("/app/test")
                    .withObject("data", ArouterTest("Jack", 5))
                    .navigation()
                4 -> ActivityUtils.startActivity(LazyActivity::class.java)
                else -> LogUtils.d("快速点击")

            }
        }
    }


}
